<meta charset="utf-8"/>
<div class="breadcrumbs" id="breadcrumbs">
    <ul class="breadcrumb">
        <li><i class="ace-icon fa fa-home home-icon"></i>
            <a href="index">主页</a>
        </li>

        <li><span>控制台</span></li>
    </ul>
    <!-- /.breadcrumb -->
</div>

<script type="text/javascript" src="js/laypage.js"></script>
<!-- 第一个tab -->

<!-- 默认执行第二个tab -->
<script type="text/javascript">
    function ypckkk() {
        pageChange2(1);
    }
</script>
<script type="text/javascript">
    //重置查询
    function chongZhi() {
        var a = "";
        $.post("MJTZ/djy", {
            "wlbm": a
        }, function () {
            pageChange(1);
        });
    }

    /* 填充表格 */
    function trList(data) {
        var dataStr = "";
        $.each(data, function (i, a) {
            $.each(a.wgjy.list, function (i, v) { //v. _ rscjh表数据   a.paginate.list -->v
                dataStr += '<tr>';
                dataStr += '<td class="hidden-20"><input name="checkboxs1"  id="checkboxs1" class="ace" type="checkbox" value="' + v.id + '"/> <span class="lbl"></span></td>';
                dataStr += '<td>' + v.wlbm + '</td>';
                dataStr += '<td>' + v.wlmc + '</td>';
                dataStr += '<td>' + v.ggxh + '</td>';
                dataStr += '<td>' + v.dw + '</td>';
                dataStr += '<td>' + '待传递' + '</td>';
                dataStr += '<td><div class="hidden-sm hidden-xs action-buttons"><a href="';
                dataStr += 'javascript:SHOWMSG(' + v.jydh + ',\'' + v.jyr + '\',\'' + v.jysj + '\',\'' + v.xqdh + '\',\'' + v.wlbm;
                dataStr += '\',\'' + v.wlmc + '\',\'' + v.ggxh + '\',\'' + v.dw + '\',\'' + v.bhpc + '\',\'' + v.ckwj + '\',\'' + v.bz;
                dataStr += '\')" class="blue"> <i class="ace-icon fa fa-search-plus bigger-130"></i> </a> ';

                dataStr += '<a href="javascript:UPDATEWGJY(' + v.id + ',\'' + v.xqdh + '\',\'' + v.wlbm + '\',\'' + v.wlmc + '\',\'' + v.ggxh + '\',\'' + v.dw + '\',\'' + v.bhpc + '\',' + v.ckwj + ',\'' + v.bz + '\')"';
                dataStr += ' class="green "><i class="ace-icon fa fa-pencil bigger-130"></i> </a> <a href="javascript:deleteU(' + v.id + ')" class="red"> <i class="ace-icon fa fa-trash-o bigger-130"></i> </a></div> </td></tr>';
            });

        });
        // 把拼接好的表格内容填充到指定位置
        $("#tbody_1").html(dataStr);

    }

    function trList3(data) {
        var dataStr = "";
        $.each(data, function (i, a) {
            $.each(a.jy.list, function (i, v) { //v. _ rscjh表数据   a.paginate.list -->v
                dataStr += '<tr>';
                dataStr += '<td>' + v.wlbm + '</td>';
                dataStr += '<td>' + v.xqdh + '</td>';
                dataStr += '<td>' + v.wlmc + '</td>';
                dataStr += '<td>' + v.ggxh + '</td>';
                dataStr += '<td>' + v.dw + '</td>';
                dataStr += '<td>' + '采购单号' + '</td>';
                dataStr += '<td style="display: none">' + '<input name="id' + i + '" type="text" value="' + v.id + '">' + '</td>';
                dataStr += '<td>' + '<input name="sjsl' + i + '" type="text" style="width: 70px;height: 22px">' + '</td>';
                dataStr += '<td>' + '<input name="cysl' + i + '" type="text" style="width: 70px;height: 22px">' + '</td>';
                dataStr += '<td>' + '<input name="yjy' + i + '" type="text" style="width: 70px;height: 22px">' + '</td>';
                dataStr += '<td>' + '<input name="wjy' + i + '" type="text" style="width: 70px;height: 22px">' + '</td>';
                dataStr += '<td>' + '<input name="hgsl' + i + '" type="text" style="width: 70px;height: 22px">' + '</td>';
                dataStr += '<td>' + '<input name="bhgsl' + i + '" type="text" style="width: 70px;height: 22px">' + '</td>';
                dataStr += '<td>' + '供应商' + '</td>';
                dataStr += '<td>' + '外观' + '</td>';
                dataStr += '<td>' + '其他' + '</td>';
                dataStr += '<td>' + '参考文件' + '</td></tr>';
            });

        });
        // 把拼接好的表格内容填充到指定位置
        $("#tbody_3").html(dataStr);

    }

    $("#submi").click(function () {


        $.post("MJTZ/djy", $("#main").serialize(), function (data) {
            pageChange(1);
        });
    });

    function trPost(data) {
        if (data.totalPage != 1) {
            $("#laypage_3").addClass("hide");
            $("#get_pagination3").removeClass("hide");
            laypage({
                cont: $('#get_pagination3'), //容器。值支持id名、原生dom对象，jquery对象,
                pages: data.totalPage, //总页数
                skip: true, //是否开启跳页
                skin: '#2283C5', //保持ace中间的样式
                first: 1,
                last: data.totalPage, //总页数，将尾页显示为总页数
                curr: data.pageNumber, //当前页
                groups: 5, //连续显示分页数
                jump: function (obj, first) {
                    if (!first) { //一定要加此判断，否则初始时会无限刷新
                        pageChange(obj.curr);
                    }
                }
            });
        } else {
            $("#get_pagination3").addClass("hide");
            $("#laypage_3").removeClass("hide");
        }

    }

    function pageChange(curr) {
        $.get("MJTZ/djy", {
            "pageNumber": curr
        }, function (data) {
            trList(data); //调用上面trList()方法，填充表格数据
            trPost(data[0].wgjy);
            laypage({
                cont: $('#pages'), //容器。值支持id名、原生dom对象，jquery对象,
                pages: data[0].wgjy.totalPage, //总页数
                skip: true, //是否开启跳页
                skin: 'molv', //设置信息流模式样式
                last: data[0].wgjy.totalPage, //总页数，将尾页显示为总页数
                curr: data[0].wgjy.pageNumber, //当前页
                groups: 3, //连续显示分页数
                jump: function (obj, first) {
                    if (!first) { //一定要加此判断，否则初始时会无限刷新
                        pageChange(obj.curr);
                    }

                }
            });

        });
    }

    function deleteU(id) {

        layer.confirm('是否确定删除此条数据？', {
            btn: ['确定', '取消']
        }, function () {
            $.post("MJTZ/delete", {
                "id": id
            }, function () {
                layer.msg("已删除");
                pageChange(1);
            });
        }, function () {
            layer.msg("已取消");
        });
    }

    pageChange(1);

    /*复选框js_全选  */
    $('table th input:checkbox').on('click',
        function () {
            var that = this;
            $(this).closest('table').find(
                'tr > td:first-child input:checkbox').each(function () {
                this.checked = that.checked;
                $(this).closest('tr').toggleClass('selected');
            });
        });

    //显示检验信息
    function SHOWMSG2(jydh, jyr, jysj, xqdh, wlbm, wlmc, ggxh, dw, bhpc, ckwj, bz, sjsl, cysl, hgsl, bhgsl) {
        document.getElementById("show").reset();
        $("#user_id1").val(jydh);
        $("#user_username1").val(jyr);
        $("#user_name1").val(jysj);
        $("#user_gender1").val(xqdh);
        $("#user_age1").val(wlbm);
        $("#user_dept1").val(wlmc);
        $("#user_position1").val(ggxh);
        $("#user_education1").val(dw);
        $("#user_sjsl").val(sjsl);
        $("#user_cysl").val(cysl);
        $("#user_hgsl").val(hgsl);
        $("#user_bhgsl").val(bhgsl);
        $("#user_hiredate1").val(bhpc);
        $("#user_seniority1").val(ckwj);
        $("#user_email1").val(bz);
        $('#sh').removeClass("hide");
        $('#jd').removeClass('hide');
        $('#jr').removeClass('hide');
        $('#jsj').removeClass('hide');
        $('#sjsl').removeClass('hide');
        $('#cysl').removeClass('hide');
        $('#hgsl').removeClass('hide');
        $('#bhgsl').removeClass('hide');
        userModel = layer.open({
            type: 1,
            shade: [0.5],
            title: '检验单', //不显示标题
            area: ['40%', '90%'], //显示空间
            content: $('#sh'), //捕获的元素
            btn: ['关闭'],
            yes: function (index, layero) { //或者使用btn1
                $.post("sh", $("#show").serialize(), function (data) {

                    layer.close(index);
                    $('#sh').addClass("hide");
                    //document.getElementById("show").submit();
                });
            },
            cancel: function (index) {
                layer.close(index);
                $('#sh').addClass("hide"); //取消继续隐藏
            },
        });
    };

    //显示检验信息
    function SHOWMSG(jydh, jyr, jysj, xqdh, wlbm, wlmc, ggxh, dw, bhpc, ckwj, bz) {
        document.getElementById("show").reset();
        $("#user_gender1").val(xqdh);
        $("#user_age1").val(wlbm);
        $("#user_dept1").val(wlmc);
        $("#user_position1").val(ggxh);
        $("#user_education1").val(dw);
        $("#user_hiredate1").val(bhpc);
        $("#user_seniority1").val(ckwj);
        $("#user_email1").val(bz);
        $('#sh').removeClass("hide");
        $('#jd').addClass('hide');
        $('#jr').addClass('hide');
        $('#jsj').addClass('hide');
        $('#sjsl').addClass('hide');
        $('#cysl').addClass('hide');
        $('#hgsl').addClass('hide');
        $('#bhgsl').addClass('hide');
        userModel = layer.open({
            type: 1,
            shade: [0.5],
            title: '检验单', //不显示标题
            area: ['40%', '65%'], //显示空间
            content: $('#sh'), //捕获的元素
            btn: ['关闭'],
            yes: function (index, layero) { //或者使用btn1
                $.post("sh", $("#show").serialize(), function (data) {

                    layer.close(index);
                    $('#sh').addClass("hide");
                    //document.getElementById("show").submit();
                });
            },
            cancel: function (index) {
                layer.close(index);
                $('#sh').addClass("hide"); //取消继续隐藏
            },
        });
    };

    //新增
    function ADDNEW() {
        document.getElementById("pform").reset();
        $('#add').removeClass("hide");
        userModel = layer.open({
            type: 1,
            shade: [0.5],
            title: '新增检验单', //不显示标题
            area: ['40%', '60%'], //显示空间
            content: $('#add'), //捕获的元素
            btn: ['添加', '取消'],
            yes: function (index, layero) { //或者使用btn1
                var xqdh = document.getElementById("xqdh").value;
                var wlbm = document.getElementById("wlbm").value;
                var wlmc = document.getElementById("wlmc").value;
                var ggxh = document.getElementById("ggxh").value;
                var dw = document.getElementById("dw").value;
                var bhpc = document.getElementById("bhpc").value;

                if (xqdh == "") {
                    errorMsg("需求单号不能为空");
                    return false;
                }
                if (wlbm == "") {
                    errorMsg("物料编码不能为空");
                    return false;
                }
                if (wlmc == "") {
                    errorMsg("物料名称不能为空");
                    return false;
                }
                if (ggxh == "") {
                    errorMsg("规格型号不能为空");
                    return false;
                }
                if (dw == "") {
                    errorMsg("单位不能为空");
                    return false;
                }
                if (bhpc == "") {
                    errorMsg("单位批次不能为空");
                    return false;
                }

                $.post("MJTZ/addjy", $("#pform").serialize(), function () {
                    layer.close(index);
                    $('#add').addClass("hide");
                    pageChange(1);
                    layer.msg("添加成功");
                    //document.getElementById("pform").submit();
                });
            },
            cancel: function (index) {
                layer.close(index);
                $('#add').addClass("hide"); //取消继续隐藏
                layer.msg("已取消");
            },
        });
    };

    <!-- 更新用户 -->
    function UPDATEWGJY(id, xqdh, wlbm, wlmc, ggxh, dw, bhpc, ckwj, bz) {
        document.getElementById("uup").reset();
        $("#wgjy_id").val(id);
        $("#wgjy_xqdh").val(xqdh);
        $("#wgjy_wlbm").val(wlbm);
        $("#wgjy_wlmc").val(wlmc);
        $("#wgjy_ggxh").val(ggxh);
        $("#wgjy_dw").val(dw);
        $("#wgjy_bhpc").val(bhpc);
        $("#wgjy_ckwj").val(ckwj);
        $("#wgjy_bz").val(bz);
        $('#sjsl2').addClass('hide');
        $('#cysl2').addClass('hide');
        $('#hgsl2').addClass('hide');
        $('#bhgsl2').addClass('hide');
        $('#up').removeClass("hidden");
        userModel = layer.open({
            type: 1,
            shade: [0.5],
            title: '更新', //不显示标题
            area: ['40%', '65%'], //显示空间
            content: $('#up'), //捕获的元素
            btn: ['更新', '取消'],
            yes: function (index, layero) { //或者使用btn1
                var xqdh = document.getElementById("wgjy_xqdh").value;
                var wlbm = document.getElementById("wgjy_wlbm").value;
                var wlmc = document.getElementById("wgjy_wlmc").value;
                var ggxh = document.getElementById("wgjy_ggxh").value;
                var dw = document.getElementById("wgjy_dw").value;
                var bhpc = document.getElementById("wgjy_bhpc").value;
                var ckwj = document.getElementById("wgjy_ckwj").value;
                var bz = document.getElementById("wgjy_bz").value;

                if (xqdh == "") {
                    errorMsg("需求单号不能为空");
                    return false;
                }
                if (wlbm == "") {
                    errorMsg("物料编码不能为空");
                    return false;
                }
                if (wlmc == "") {
                    errorMsg("物料名称不能为空");
                    return false;
                }
                if (ggxh == "") {
                    errorMsg("规格型号不能为空");
                    return false;
                }
                if (dw == "") {
                    errorMsg("单位不能为空");
                    return false;
                }
                if (bhpc == "") {
                    errorMsg("编号批次不能为空");
                    return false;
                }

                $.post("MJTZ/updatejy", $("#uup").serialize(), function (data) {
                    if (data == "success") {
                        layer.close(index);
                        $('#up').addClass("hidden");
                        pageChange(1);
                        layer.msg("修改成功");
                    }

                    //document.getElementById("uup").submit();
                });
            },
            cancel: function (index) {
                layer.close(index);
                $('#up').addClass("hidden"); //取消继续隐藏
                layer.msg("已取消");
            },
        });
    };

    <!-- 更新用户 -->
    function UPDATEWGJY2(id, xqdh, wlbm, wlmc, ggxh, dw, bhpc, ckwj, bz, sjsl, cysl, hgsl, bhgsl) {
        document.getElementById("uup").reset();
        $("#wgjy_id").val(id);
        $("#wgjy_xqdh").val(xqdh);
        $("#wgjy_wlbm").val(wlbm);
        $("#wgjy_wlmc").val(wlmc);
        $("#wgjy_ggxh").val(ggxh);
        $("#wgjy_dw").val(dw);
        $("#wgjy_bhpc").val(bhpc);
        $("#wgjy_ckwj").val(ckwj);
        $("#wgjy_sjsl").val(sjsl);
        $("#wgjy_cysl").val(cysl);
        $("#wgjy_hgsl").val(hgsl);
        $("#wgjy_bhgsl").val(bhgsl);
        $("#wgjy_bz").val(bz);
        $('#sjsl2').removeClass('hide');
        $('#cysl2').removeClass('hide');
        $('#hgsl2').removeClass('hide');
        $('#bhgsl2').removeClass('hide');
        $('#up').removeClass("hidden");
        userModel = layer.open({
            type: 1,
            shade: [0.5],
            title: '更新', //不显示标题
            area: ['40%', '85%'], //显示空间
            content: $('#up'), //捕获的元素
            btn: ['更新', '取消'],
            yes: function (index, layero) { //或者使用btn1
                var xqdh = document.getElementById("wgjy_xqdh").value;
                var wlbm = document.getElementById("wgjy_wlbm").value;
                var wlmc = document.getElementById("wgjy_wlmc").value;
                var ggxh = document.getElementById("wgjy_ggxh").value;
                var dw = document.getElementById("wgjy_dw").value;
                var bhpc = document.getElementById("wgjy_bhpc").value;
                var ckwj = document.getElementById("wgjy_ckwj").value;
                var bz = document.getElementById("wgjy_bz").value;
                var sjsl = document.getElementById("wgjy_sjsl").value;
                var cysl = document.getElementById("wgjy_cysl").value;
                var hgsl = document.getElementById("wgjy_hgsl").value;
                var bhgsl = document.getElementById("wgjy_bhgsl").value;
                if (xqdh == "") {
                    errorMsg("需求单号不能为空");
                    return false;
                }
                if (wlbm == "") {
                    errorMsg("物料编码不能为空");
                    return false;
                }
                if (wlmc == "") {
                    errorMsg("物料名称不能为空");
                    return false;
                }
                if (ggxh == "") {
                    errorMsg("规格型号不能为空");
                    return false;
                }
                if (dw == "") {
                    errorMsg("单位不能为空");
                    return false;
                }
                if (bhpc == "") {
                    errorMsg("编号批次不能为空");
                    return false;
                }
                if (sjsl == "") {
                    errorMsg("送检数量不能为空");
                    return false;
                }
                if (cysl == "") {
                    errorMsg("抽样数量不能为空");
                    return false;
                }
                if (hgsl == "") {
                    errorMsg("合格数量不能为空");
                    return false;
                }
                if (bhgsl == "") {
                    errorMsg("不合格数量不能为空");
                    return false;
                }

                $.post("MJTZ/updatejy", $("#uup").serialize(), function (data) {
                    if (data == "success") {
                        layer.close(index);
                        $('#up').addClass("hidden");
                        pageChange(1);
                        layer.msg("修改成功");
                    }

                    //document.getElementById("uup").submit();
                });
            },
            cancel: function (index) {
                layer.close(index);
                $('#up').addClass("hidden"); //取消继续隐藏
                layer.msg("已取消");
            },
        });
    };

    //检验操作
    function SHOWJY() {
        var ls = $("input[type=checkbox]:checked").size(); //选中的个数
        if (ls != "") {
            $('#boom').removeClass("hide");
            var idlist = '';
            $("input[type='checkbox'][name='checkboxs1']").filter(
                ':checked').each(function () {
                idlist = idlist + $(this).val() + ",";
            });
            if (idlist.length > 0) {
                idlist = idlist.substring(0, idlist.length - 1);
                $.post("MJTZ/jy", {
                    "idlist": idlist,
                }, function (data) {
                    trList3(data);
                });
            }

            userModel = layer.open({
                type: 1,
                shade: [0.5],
                title: '检验单', //不显示标题
                area: ['98%', '70%'], //显示空间
                content: $('#boom'), //捕获的元素
                btn: ['确定', '关闭'],
                yes: function (index, layero) { //或者使用btn1
                    $.post("MJTZ/jywc", $("#tform").serialize(), function (data) {

                        //判断表单中是否为空
                        var inputs = document.getElementById("boom").getElementsByTagName("INPUT");
                        for (var i = 0; i < inputs.length; i++) {
                            if (inputs[i].value == "" || inputs[i].value == null) {
                                layer.alert("输入框信息不能为空");
                                inputs[i].focus();
                                return (false);
                            }
                        }

                        if (data = "success") {
                            layer.alert("检验完成!")
                            pageChange(1);
                        }
                        layer.close(index);
                        $('#boom').addClass("hide");
                        //document.getElementById("show").submit();
                    });
                },
                cancel: function (index) {
                    layer.close(index);
                    $('#sh').addClass("hide"); //取消继续隐藏
                },
            });
        } else {
            layer.alert("请合理操作！")
        }
    }

</script>
<!-- 更改每页显示数据的数目 -->
<script type="text/javascript">
    var sel = document.getElementById("sel");
    sel.onchange = function () {
        /* alert(sel.options[sel.selectedIndex].value); */
        $.post("MJTZ/fanye", {
            "infNumber": sel.options[sel.selectedIndex].value
        }, function (data) {
            pageChange(1);
        });
    }
</script>

<!-- 第二个tab -->
<script type="text/javascript">
    //重置查询
    function chongZhi2() {
        var a = "";
        $.post("MJTZ/yjy", {
            "wlbm": a
        }, function () {
            pageChange2(1);
        });
    }

    /* 填充表格 */
    function trList2(data) {

        var dataStr = "";
        $.each(data, function (i, a) {
            $.each(a.wgjy.list, function (i, v) { //v. _ rscjh表数据   a.paginate.list -->v
                dataStr += '<tr>';
                dataStr += '<td class="hidden-20"><input name="checkboxs1"  id="checkboxs1" class="ace" type="checkbox" value="' + v.id + '"/> <span class="lbl"></span></td>';
                dataStr += '<td>' + v.wlbm + '</td>';
                dataStr += '<td>' + v.wlmc + '</td>';
                dataStr += '<td>' + v.ggxh + '</td>';
                dataStr += '<td>' + v.dw + '</td>';
                dataStr += '<td>' + '待传递' + '</td>';

                dataStr += '<td><div class="hidden-sm hidden-xs action-buttons"><a href="';
                dataStr += 'javascript:SHOWMSG2(\'' + v.jydh + '\',\'' + v.jyr + '\',\'' + v.jysj + '\',\'' + v.xqdh + '\',\'' + v.wlbm;
                dataStr += '\',\'' + v.wlmc + '\',\'' + v.ggxh + '\',\'' + v.dw + '\',\'' + v.bhpc + '\',\'' + v.ckwj + '\',\'' + v.bz + '\',\'' + v.sjsl + '\',\'' + v.cysl + '\',\'' + v.hgsl + '\',\'' + v.bhgsl;
                dataStr += '\')" class="blue"> <i class="ace-icon fa fa-search-plus bigger-130"></i> </a> ';
                dataStr += '<a href="javascript:UPDATEWGJY2(' + v.id + ',\'' + v.xqdh + '\',\'' + v.wlbm + '\',\'' + v.wlmc + '\',\'' + v.ggxh + '\',\'' + v.dw + '\',\'' + v.bhpc + '\',\'' + v.ckwj + '\',\'' + v.bz + '\',\'' + v.sjsl + '\',\'' + v.cysl + '\',\'' + v.hgsl + '\',\'' + v.bhgsl + '\')"';
                dataStr += ' class="green "><i class="ace-icon fa fa-pencil bigger-130"></i> </a> <a href="javascript:deleteU2(' + v.id + ')" class="red"> <i class="ace-icon fa fa-trash-o bigger-130"></i> </a></div> </td></tr>';
            });

        });
        // 把拼接好的表格内容填充到指定位置
        $("#tbody_2").html(dataStr);

    }

    $("#submi2").click(function () {
        $.post("MJTZ/yjy", $("#main2").serialize(), function (data) {
            pageChange2(1);
        });
    });

    function trPost2(data) {
        if (data.totalPage != 1) {
            $("#laypage_4").addClass("hide");
            $("#get_pagination4").removeClass("hide");
            laypage({
                cont: $('#get_pagination4'), //容器。值支持id名、原生dom对象，jquery对象,
                pages: data.totalPage, //总页数
                skip: true, //是否开启跳页
                skin: '#2283C5', //保持ace中间的样式
                first: 1,
                last: data.totalPage, //总页数，将尾页显示为总页数
                curr: data.pageNumber, //当前页
                groups: 5, //连续显示分页数
                jump: function (obj, first) {
                    if (!first) { //一定要加此判断，否则初始时会无限刷新
                        pageChange2(obj.curr);
                    }
                }
            });
        } else {
            $("#get_pagination4").addClass("hide");
            $("#laypage_4").removeClass("hide");
        }

    }

    function pageChange2(curr) {
        $.get("MJTZ/yjy", {
            "pageNumber": curr
        }, function (data) {
            trList2(data); //调用上面trList()方法，填充表格数据
            trPost2(data[0].wgjy);
            laypage({
                cont: $('#pages'), //容器。值支持id名、原生dom对象，jquery对象,
                pages: data[0].wgjy.totalPage, //总页数
                skip: true, //是否开启跳页
                skin: 'molv', //设置信息流模式样式
                last: data[0].wgjy.totalPage, //总页数，将尾页显示为总页数
                curr: data[0].wgjy.pageNumber, //当前页
                groups: 3, //连续显示分页数
                jump: function (obj, first) {
                    if (!first) { //一定要加此判断，否则初始时会无限刷新
                        pageChange2(obj.curr);
                    }

                }
            });

        });
    }

    function deleteU2(id) {

        layer.confirm('是否确定删除此条数据？', {
            btn: ['确定', '取消']
        }, function () {
            $.post("MJTZ/delete", {
                "id": id
            }, function () {
                layer.msg("已删除");
                pageChange2(1);
            });
        }, function () {
            layer.msg("已取消");
        });
    }

    pageChange2(1);

    $('table th input:checkbox').on('click',
        function () { /*复选框js_全选  */
            var that = this;
            $(this).closest('table').find(
                'tr > td:first-child input:checkbox').each(function () {
                this.checked = that.checked;
                $(this).closest('tr').toggleClass('selected');
            });

        });
</script>
<!-- 更改每页显示数据的数目 -->
<script type="text/javascript">
    var sel2 = document.getElementById("sel2");
    sel2.onchange = function () {
        $.post("MJTZ/fanye2", {
            "infNumber2": sel2.options[sel2.selectedIndex].value
        }, function (data) {
            pageChange2(1);
        });
    }
</script>

<div class="page-content">

    <div class="row">
        <div class="col-xs-12">

            <div class="tabbable">

                <ul class="nav nav-tabs">
                    <li class="active">
                        <a href="#tab1" data-toggle="tab">待检验</a>
                    </li>
                    <li>
                        <a href="#tab2" data-toggle="tab" onclick="javascript:ypckkk();">已检验</a>
                    </li>
                </ul>
            </div>

            <div class="tab-content">
                <!-- 不同的内容 -->
                <div class="tab-pane active" id="tab1">

                    <div class="row">
                        <div class="col-xs-12">
                            <div class="clearfix"></div>
                            <div class="table-header">待检验</div>

                            <!-- div.table-responsive -->

                            <!-- div.dataTables_borderWrap -->
                            <div>
                                <div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
                                    <form method="post" action="MJTZ/djy" id="main">
                                        <div class="row">
                                            <div class="col-xs-12">
                                                物料编码:<input type="text" placeholder="物料编码" class="form-control"
                                                            name="wlbm"/>
                                                物料名称:<input type="text" placeholder="物料名称" class="form-control"
                                                            name="wlmc"/>
                                                <a class="btn btn-sm btn-primary" id="submi">查询</a>
                                                <input type="reset" class="btn btn-sm btn-primary"
                                                       onclick="javascript:chongZhi()" value="重置">
                                                <div class="pull-right">
                                                    <a class="btn btn-sm btn-primary" href="javascript:ADDNEW()">新增</a>
                                                    <a class="btn btn-sm btn-primary" href="javascript:SHOWJY()">检验</a>
                                                </div>
                                            </div>

                                        </div>
                                    </form>

                                    <table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
                                           role="grid">
                                        <thead>
                                        <tr role="row">
                                            <th class="center" style="width:9px; "><label> <input type="checkbox"
                                                                                                  class="ace"/> <span
                                                    class="lbl"></span></label></th>
                                            <th>物料编码</th>
                                            <th>物料名称</th>
                                            <th>规格型号</th>
                                            <th>单位</th>
                                            <th>数量</th>
                                            <th width="120">操作</th>

                                        </tr>
                                        </thead>
                                        <tbody id="tbody_1">

                                        </tbody>

                                    </table>

                                    <div class="row">
                                        <div class="col-xs-12">

                                            <div class="dataTables_paginate paging_simple_numbers  pull-left">
                                                <label>显示<select name="dynamic-table_length"
                                                                 aria-controls="dynamic-table"
                                                                 class="form-control input-sm" id="sel">
                                                    <option value="10">10</option>
                                                    <option value="20">20</option>
                                                    <option value="50">50</option>
                                                    <option value="100">100</option>
                                                </select> 条记录</label>
                                            </div>
                                            <div class="dataTables_paginate paging_simple_numbers">
                                                <ul class="pagination" id="get_pagination3">
                                                </ul>
                                                <div class="laypage_main laypageskin_molv" id="laypage_3">
                                                    <span class="laypage_curr" style="background-color:#2283C5">1</span><span
                                                        class="laypage_total"><label>到第</label><input max="1"
                                                                                                      min="1"
                                                                                                      class="laypage_skip"
                                                                                                      type="number"><label>页</label>
												<button type="button" class="laypage_btn">
													确定
													</button>
											</span>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 第一个tab结束 -->

                <div class="tab-pane" id="tab2">
                    <div class="table-header">已检验</div>

                    <!-- div.table-responsive -->

                    <!-- div.dataTables_borderWrap -->
                    <div>
                        <div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
                            <form method="post" action="MJTZ/yjy" id="main2">
                                <div class="row">
                                    <div class="col-xs-12">
                                        物料编码:<input type="text" placeholder="物料编码" class="form-control" name="wlbm"/>
                                        物料名称:<input type="text" placeholder="物料名称" class="form-control" name="wlmc"/>
                                        <a class="btn btn-sm btn-primary" id="submi2">查询</a>
                                        <input type="reset" class="btn btn-sm btn-primary"
                                               onclick="javascript:chongZhi2()" value="重置">
                                    </div>

                                </div>
                            </form>

                            <table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
                                   role="grid">
                                <thead>
                                <tr role="row">
                                    <th class="center" style="width:9px; "><label> <input type="checkbox" class="ace"/>
                                        <span class="lbl"></span></label></th>
                                    <th>物料编码</th>
                                    <th>物料名称</th>
                                    <th>规格型号</th>
                                    <th>单位</th>
                                    <th>数量</th>
                                    <th width="120">操作</th>

                                </tr>
                                </thead>
                                <tbody id="tbody_2">

                                </tbody>

                            </table>

                            <div class="row">
                                <div class="col-xs-12">

                                    <div class="dataTables_paginate paging_simple_numbers  pull-left">
                                        <label>显示<select name="dynamic-table_length"
                                                         aria-controls="dynamic-table" class="form-control input-sm"
                                                         id="sel">
                                            <option value="10">10</option>
                                            <option value="20">20</option>
                                            <option value="50">50</option>
                                            <option value="100">100</option>
                                        </select> 条记录</label>
                                    </div>
                                    <div class="dataTables_paginate paging_simple_numbers">
                                        <ul class="pagination" id="get_pagination4">
                                        </ul>
                                        <div class="laypage_main laypageskin_molv" id="laypage_4">
                                            <span class="laypage_curr" style="background-color:#2283C5">1</span><span
                                                class="laypage_total"><label>到第</label><input max="1"
                                                                                              min="1"
                                                                                              class="laypage_skip"
                                                                                              type="number"><label>页</label>
												<button type="button" class="laypage_btn">
													确定
													</button>
											</span>
                                        </div>
                                    </div>

                                </div>
                            </div>

                        </div>
                    </div>
                </div>
                <!-- 第二个结束 -->

            </div>
        </div>
    </div>

    <!-- 检验弹窗 -->
    <div class="hide" id="boom">
        <form id="tform" method="post">
            <table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
                   role="grid">
                <thead>
                <tr role="row">
                    <th>物料编码</th>
                    <th>需求单号</th>
                    <th>物料名称</th>
                    <th>规格/型号</th>
                    <th>单位</th>
                    <th>采购单号</th>
                    <th>送检数量</th>
                    <th>抽样数量</th>
                    <th>已检验</th>
                    <th>未检验</th>
                    <th>合格数量</th>
                    <th>不合格数量</th>
                    <th>供应商</th>
                    <th>外观</th>
                    <th>其他</th>
                    <th>参考文件</th>
                </tr>
                </thead>
                <tbody id="tbody_3">
                <!-- 填充的内容 -->
                </tbody>
            </table>
        </form>
    </div>

    <!-- 新增 -->
    <div class="hide" id="add">
        <div class="col-xs-1"></div>
        <div class="col-xs-9">
            <form id="pform" method="post">
                <!-- <input type="hidden" name="role.role_id"> -->

                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">需求单号</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="wgjy.xqdh" id="xqdh" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">物料编码</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="wgjy.wlbm" id="wlbm" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">物料名称</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="wgjy.wlmc" id="wlmc" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">规格型号</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="wgjy.ggxh" id="ggxh" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">单位</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="wgjy.dw" id="dw" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">编号批次</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="wgjy.bhpc" id="bhpc" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">参考文件</label>
                    <div class="col-sm-8">
                        <input type="file" class="file form-control" name="uploadfile" id="ckwj"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">备注</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="wgjy.bz" id="bz" value=""/>
                    </div>
                </div>


            </form>
        </div>
        <div class="col-xs-2"></div>
    </div>

    <!-- 更新检验单 -->
    <div class="hidden" id="up">
        <div class="col-xs-1"></div>
        <div class="col-xs-9">
            <form id="uup" method="post">
                <input type="hidden" name="s.id" id="wgjy_id">
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">需求单号</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.xqdh" id="wgjy_xqdh" value=''/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">物料编码</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.wlbm" id="wgjy_wlbm" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">物料名称</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.wlmc" id="wgjy_wlmc" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">规格型号</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.ggxh" id="wgjy_ggxh" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">
                        单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.dw" id="wgjy_dw" value=""/>
                    </div>
                </div>

                <div class="form-group" id="sjsl2">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">送检数量</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.bhpc" id="wgjy_sjsl" value=""/>
                    </div>
                </div>
                <div class="form-group" id="cysl2">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">抽样数量</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.bhpc" id="wgjy_cysl" value=""/>
                    </div>
                </div>
                <div class="form-group" id="hgsl2">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">合格数量</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.bhpc" id="wgjy_hgsl" value=""/>
                    </div>
                </div>
                <div class="form-group" id="bhgsl2">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">
                        不&nbsp;&nbsp;合&nbsp;&nbsp;格</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.bhpc" id="wgjy_bhgsl" value=""/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">编号批次</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.bhpc" id="wgjy_bhpc" value=""/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">参考文件</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.ckwj" id="wgjy_ckwj" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1">
                        备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</label>
                    <div class="col-sm-8" style="float: left">
                        <input type="text" class="form-control" name="s.bz" id="wgjy_bz" value=""/>
                    </div>
                </div>

            </form>
        </div>
        <div class="col-xs-2"></div>
    </div>

    <!-- 检验详细信息 -->
    <div class="hide" id="sh">
        <div class="col-xs-2"></div>
        <div class="col-xs-8">

            <form id="show" method="post">
                <!-- <input type="hidden" name="role.role_id"> -->

                <div class="form-group" id="jd">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">检验单号</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_id1"/>
                    </div>
                </div>
                <div class="form-group" id="jr">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                        检&nbsp;&nbsp;验&nbsp;&nbsp;人</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_username1"/>
                    </div>
                </div>
                <div class="form-group" id="jsj">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">检验时间</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_name1"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">需求单号</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_gender1"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">物料编码</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_age1"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">物料名称</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_dept1"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">规格型号</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_position1"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                        单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_education1"/>
                    </div>
                </div>
                <div class="form-group" id="sjsl">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">送检数量</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_sjsl"/>
                    </div>
                </div>
                <div class="form-group" id="cysl">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">抽样数量</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_cysl"/>
                    </div>
                </div>
                <div class="form-group" id="hgsl">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">合格数量</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_hgsl"/>
                    </div>
                </div>
                <div class="form-group" id="bhgsl">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                        不&nbsp;&nbsp;合&nbsp;&nbsp;格</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_bhgsl"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">编号批次</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_hiredate1"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">参考文件</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_seniority1"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                        备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="user_email1"/>
                    </div>
                </div>
            </form>

        </div>
        <div class="col-xs-2"></div>
    </div>

    <!-- 添加用户 -->

    <script type="text/javascript">
        jQuery(function ($) {
            $.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
                _title: function (title) {
                    var $title = this.options.title || '&nbsp;';
                    if (("title_html" in this.options) &&
                        this.options.title_html == true)
                        title.html($title);
                    else
                        title.text($title);
                }
            }));

            //initiate dataTables plugin						初始化表格插件
            /* var oTable1 = $('#dynamic-table')
            //.wrap("<div class='dataTables_borderWrap' />")   //if you are applying horizontal scrolling (sScrollX)
            .dataTable({
                bAutoWidth : false,
                "aoColumns" : [ null, null, null, null, null, null, {
                    "bSortable" : false
                } ],
                "aaSorting" : [],

            }); */
            //oTable1.fnAdjustColumnSizing();
            //TableTools settings
            TableTools.classes.container = "btn-group btn-overlap";
            TableTools.classes.print = {
                "body": "DTTT_Print",
                "info": "tableTools-alert gritter-item-wrapper gritter-info gritter-center white",
                "message": "tableTools-print-navbar"
            };

            //initiate TableTools extension
            var tableTools_obj = new $.fn.dataTable.TableTools(
                oTable1, {
                    "sSwfPath": "plugins/ace/assets/js/dataTables/extensions/TableTools/swf/copy_csv_xls_pdf.swf", //in Ace demo plugins/ace/assets will be replaced by correct assets path

                    "sRowSelector": "td:not(:last-child)",
                    "sRowSelect": "multi",
                    "fnRowSelected": function (row) {
                        //check checkbox when row is selected
                        try {
                            $(row).find('input[type=checkbox]').get(0).checked = true
                        } catch (e) {
                        }
                    },
                    "fnRowDeselected": function (row) {
                        //uncheck checkbox
                        try {
                            $(row).find('input[type=checkbox]').get(0).checked = false
                        } catch (e) {
                        }
                    },

                    "sSelectedClass": "success",
                    "aButtons": [{
                        "sExtends": "copy",
                        "sToolTip": "复制到剪贴板",
                        "sButtonClass": "btn btn-white btn-primary btn-bold",
                        "sButtonText": "<i class='fa fa-copy bigger-110 pink'></i>",
                        "fnComplete": function () {
                            this.fnInfo(
                                '<h3 class="no-margin-top smaller">表格已复制</h3>\
                        <p>已复制 ' +
                                (oTable1.fnSettings()
                                    .fnRecordsTotal()) +
                                ' 行数据到剪贴板.</p>', 1500);
                        }
                    },

                        {
                            "sExtends": "csv",
                            "sToolTip": "导出成 CSV",
                            "sButtonClass": "btn btn-white btn-primary  btn-bold",
                            "sButtonText": "<i class='fa fa-file-excel-o bigger-110 green'></i>"
                        },

                        {
                            "sExtends": "pdf",
                            "sToolTip": "导出成 PDF",
                            "sButtonClass": "btn btn-white btn-primary  btn-bold",
                            "sButtonText": "<i class='fa fa-file-pdf-o bigger-110 red'></i>"
                        },

                        {
                            "sExtends": "print",
                            "sToolTip": "打印页面",
                            "sButtonClass": "btn btn-white btn-primary  btn-bold",
                            "sButtonText": "<i class='fa fa-print bigger-110 grey'></i>",

                            "sMessage": "<div class='navbar navbar-default'><div class='navbar-header pull-left'><a class='navbar-brand' href='#'><small>可选导航栏 &amp; 文本</small></a></div></div>",

                            "sInfo": "<h3 class='no-margin-top'>打印页面</h3>\
							  <p>请用您的浏览器打印功能打印这个表格 \
							  <br />请打印完成关闭此页面</p>",
                        }
                    ]
                });

            //we put a container before our table and append TableTools element to it
            $(tableTools_obj.fnContainer()).appendTo($('.tableTools-container'));

            //also add tooltips to table tools buttons
            //addding tooltips directly to "A" buttons results in buttons disappearing (weired! don't know why!)
            //so we add tooltips to the "DIV" child after it becomes inserted
            //flash objects inside table tools buttons are inserted with some delay (100ms) (for some reason)
            setTimeout(function () {
                $(tableTools_obj.fnContainer()).find('a.DTTT_button').each(
                    function () {
                        var div = $(this).find('> div');
                        if (div.length > 0)
                            div.tooltip({
                                container: 'body'
                            });
                        else
                            $(this).tooltip({
                                container: 'body'
                            });
                    });
            }, 200);

            //ColVis extension
            var colvis = new $.fn.dataTable.ColVis(oTable1, {
                "buttonText": "<i class='fa fa-search'></i>",
                "aiExclude": [0, 6],
                "bShowAll": true,
                //"bRestore": true,
                "sAlign": "right",
                "fnLabel": function (i, title, th) {
                    return $(th).text(); //remove icons, etc
                }

            });

            //style it
            $(colvis.button()).addClass('btn-group').find('button').addClass(
                'btn btn-white btn-info btn-bold')

            //and append it to our table tools btn-group, also add tooltip
            $(colvis.button()).prependTo('.tableTools-container .btn-group').attr(
                'title', '显示/隐藏 数据列').tooltip({
                container: 'body'
            });

            //and make the list, buttons and checkboxed Ace-like
            $(colvis.dom.collection)
                .addClass(
                    'dropdown-menu dropdown-light dropdown-caret dropdown-caret-right')
                .find('li').wrapInner('<a href="javascript:void(0)" />') //'A' tag is required for better styling
                .find('input[type=checkbox]').addClass('ace').next().addClass(
                'lbl padding-8');

            //table checkboxes
            $('th input[type=checkbox], td input[type=checkbox]').prop('checked',
                false);

            //select/deselect all rows according to table header checkbox
            $('#dynamic-table > thead > tr > th input[type=checkbox]').eq(0).on(
                'click',
                function () {
                    var th_checked = this.checked; //checkbox inside "TH" table header

                    $(this).closest('table').find('tbody > tr').each(
                        function () {
                            var row = this;
                            if (th_checked)
                                tableTools_obj.fnSelect(row);
                            else
                                tableTools_obj.fnDeselect(row);
                        });
                });

            //select/deselect a row when the checkbox is checked/unchecked
            $('#dynamic-table').on('click', 'td input[type=checkbox]', function () {
                var row = $(this).closest('tr').get(0);
                if (!this.checked)
                    tableTools_obj.fnSelect(row);
                else
                    tableTools_obj.fnDeselect($(this).closest('tr').get(0));
            });

            $(document).on('click', '#dynamic-table .dropdown-toggle', function (e) {
                e.stopImmediatePropagation();
                e.stopPropagation();
                e.preventDefault();
            });

            //And for the first simple table, which doesn't have TableTools or dataTables
            //select/deselect all rows according to table header checkbox
            var active_class = 'active';
            $('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on(
                'click',
                function () {
                    var th_checked = this.checked; //checkbox inside "TH" table header

                    $(this).closest('table').find('tbody > tr').each(
                        function () {
                            var row = this;
                            if (th_checked)
                                $(row).addClass(active_class).find(
                                    'input[type=checkbox]').eq(0).prop(
                                    'checked', true);
                            else
                                $(row).removeClass(active_class).find(
                                    'input[type=checkbox]').eq(0).prop(
                                    'checked', false);
                        });
                });

            //select/deselect a row when the checkbox is checked/unchecked
            $('#simple-table').on('click', 'td input[type=checkbox]', function () {
                var $row = $(this).closest('tr');
                if (this.checked)
                    $row.addClass(active_class);
                else
                    $row.removeClass(active_class);
            });

            /********************************/
            //add tooltip for small view action buttons in dropdown menu
            $('[data-rel="tooltip"]').tooltip({
                placement: tooltip_placement
            });

            //tooltip placement on right or left
            function tooltip_placement(context, source) {
                var $source = $(source);
                var $parent = $source.closest('table');
                var off1 = $parent.offset();
                var w1 = $parent.width();

                var off2 = $source.offset();
                //var w2 = $source.width();

                if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2))
                    return 'right';
                return 'left';
            }

        });
    </script>